package com.study.androidsystem.vibration

import com.blankj.utilcode.util.VibrateUtils
import com.study.androidsystem.R
import com.study.base.BaseActivity
import kotlinx.android.synthetic.main.activity_vibration.*
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.toast


/**
 * <pre>
 *     author : slx
 *     time   : 2020/04/14
 *     desc   :
 * </pre>
 */
class VibrationActivity : BaseActivity() {
    override fun generateLayoutId() = R.layout.activity_vibration

    override fun initView() {
        super.initView()
        testLongClick.setOnLongClickListener {
            toast("long click")
            //返回true则有触摸震动反馈
            true
        }

        startVibra.onClick {
            VibrateUtils.vibrate(longArrayOf(100, 100, 100, 100), 1)
        }

        stopVibra.onClick {
            VibrateUtils.cancel()
        }
    }
}